/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package docPlum.impl;

import docPlum.Decision;
import docPlum.Dependency;
import docPlum.DocPlumPackage;
import docPlum.DocTopic;
import docPlum.FeatureModel;
import docPlum.Group;

import java.util.Collection;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;

import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Feature Model</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link docPlum.impl.FeatureModelImpl#getHeadgroups <em>Headgroups</em>}</li>
 *   <li>{@link docPlum.impl.FeatureModelImpl#getHeaddecision <em>Headdecision</em>}</li>
 *   <li>{@link docPlum.impl.FeatureModelImpl#getHeadtopic <em>Headtopic</em>}</li>
 *   <li>{@link docPlum.impl.FeatureModelImpl#getDependencies <em>Dependencies</em>}</li>
 *   <li>{@link docPlum.impl.FeatureModelImpl#getName <em>Name</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class FeatureModelImpl extends EObjectImpl implements FeatureModel {
	/**
	 * The cached value of the '{@link #getHeadgroups() <em>Headgroups</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getHeadgroups()
	 * @generated
	 * @ordered
	 */
	protected EList<Group> headgroups;

	/**
	 * The cached value of the '{@link #getHeaddecision() <em>Headdecision</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getHeaddecision()
	 * @generated
	 * @ordered
	 */
	protected EList<Decision> headdecision;

	/**
	 * The cached value of the '{@link #getHeadtopic() <em>Headtopic</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getHeadtopic()
	 * @generated
	 * @ordered
	 */
	protected EList<DocTopic> headtopic;

	/**
	 * The cached value of the '{@link #getDependencies() <em>Dependencies</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getDependencies()
	 * @generated
	 * @ordered
	 */
	protected EList<Dependency> dependencies;

	/**
	 * The default value of the '{@link #getName() <em>Name</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getName()
	 * @generated
	 * @ordered
	 */
	protected static final String NAME_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getName() <em>Name</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getName()
	 * @generated
	 * @ordered
	 */
	protected String name = NAME_EDEFAULT;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected FeatureModelImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return DocPlumPackage.Literals.FEATURE_MODEL;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Group> getHeadgroups() {
		if (headgroups == null) {
			headgroups = new EObjectContainmentEList<Group>(Group.class, this, DocPlumPackage.FEATURE_MODEL__HEADGROUPS);
		}
		return headgroups;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Decision> getHeaddecision() {
		if (headdecision == null) {
			headdecision = new EObjectContainmentEList<Decision>(Decision.class, this, DocPlumPackage.FEATURE_MODEL__HEADDECISION);
		}
		return headdecision;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<DocTopic> getHeadtopic() {
		if (headtopic == null) {
			headtopic = new EObjectContainmentEList<DocTopic>(DocTopic.class, this, DocPlumPackage.FEATURE_MODEL__HEADTOPIC);
		}
		return headtopic;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Dependency> getDependencies() {
		if (dependencies == null) {
			dependencies = new EObjectContainmentEList<Dependency>(Dependency.class, this, DocPlumPackage.FEATURE_MODEL__DEPENDENCIES);
		}
		return dependencies;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getName() {
		return name;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setName(String newName) {
		String oldName = name;
		name = newName;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, DocPlumPackage.FEATURE_MODEL__NAME, oldName, name));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case DocPlumPackage.FEATURE_MODEL__HEADGROUPS:
				return ((InternalEList<?>)getHeadgroups()).basicRemove(otherEnd, msgs);
			case DocPlumPackage.FEATURE_MODEL__HEADDECISION:
				return ((InternalEList<?>)getHeaddecision()).basicRemove(otherEnd, msgs);
			case DocPlumPackage.FEATURE_MODEL__HEADTOPIC:
				return ((InternalEList<?>)getHeadtopic()).basicRemove(otherEnd, msgs);
			case DocPlumPackage.FEATURE_MODEL__DEPENDENCIES:
				return ((InternalEList<?>)getDependencies()).basicRemove(otherEnd, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case DocPlumPackage.FEATURE_MODEL__HEADGROUPS:
				return getHeadgroups();
			case DocPlumPackage.FEATURE_MODEL__HEADDECISION:
				return getHeaddecision();
			case DocPlumPackage.FEATURE_MODEL__HEADTOPIC:
				return getHeadtopic();
			case DocPlumPackage.FEATURE_MODEL__DEPENDENCIES:
				return getDependencies();
			case DocPlumPackage.FEATURE_MODEL__NAME:
				return getName();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case DocPlumPackage.FEATURE_MODEL__HEADGROUPS:
				getHeadgroups().clear();
				getHeadgroups().addAll((Collection<? extends Group>)newValue);
				return;
			case DocPlumPackage.FEATURE_MODEL__HEADDECISION:
				getHeaddecision().clear();
				getHeaddecision().addAll((Collection<? extends Decision>)newValue);
				return;
			case DocPlumPackage.FEATURE_MODEL__HEADTOPIC:
				getHeadtopic().clear();
				getHeadtopic().addAll((Collection<? extends DocTopic>)newValue);
				return;
			case DocPlumPackage.FEATURE_MODEL__DEPENDENCIES:
				getDependencies().clear();
				getDependencies().addAll((Collection<? extends Dependency>)newValue);
				return;
			case DocPlumPackage.FEATURE_MODEL__NAME:
				setName((String)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case DocPlumPackage.FEATURE_MODEL__HEADGROUPS:
				getHeadgroups().clear();
				return;
			case DocPlumPackage.FEATURE_MODEL__HEADDECISION:
				getHeaddecision().clear();
				return;
			case DocPlumPackage.FEATURE_MODEL__HEADTOPIC:
				getHeadtopic().clear();
				return;
			case DocPlumPackage.FEATURE_MODEL__DEPENDENCIES:
				getDependencies().clear();
				return;
			case DocPlumPackage.FEATURE_MODEL__NAME:
				setName(NAME_EDEFAULT);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case DocPlumPackage.FEATURE_MODEL__HEADGROUPS:
				return headgroups != null && !headgroups.isEmpty();
			case DocPlumPackage.FEATURE_MODEL__HEADDECISION:
				return headdecision != null && !headdecision.isEmpty();
			case DocPlumPackage.FEATURE_MODEL__HEADTOPIC:
				return headtopic != null && !headtopic.isEmpty();
			case DocPlumPackage.FEATURE_MODEL__DEPENDENCIES:
				return dependencies != null && !dependencies.isEmpty();
			case DocPlumPackage.FEATURE_MODEL__NAME:
				return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (name: ");
		result.append(name);
		result.append(')');
		return result.toString();
	}

} //FeatureModelImpl
